package com.example.test.controller;

import com.example.test.Bean.UserBean;
import com.example.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class appController {
    @Autowired
    UserService userService;
    @RequestMapping("/index")
    public String index(){
        return "index";
    }

    @RequestMapping(value = "/loginIn" ,method = RequestMethod.POST)
    public String login(String name, String password ,HttpSession session){
        UserBean userBean = userService.loginln(name, password);
        if(userBean != null){
            session.setAttribute("user",userBean);
            return "success";
        }else {
            return "errer";
        }
    }

}
